package com.lenovo.manufacture;

import android.app.Activity;
import android.app.ProgressDialog;
import android.webkit.JavascriptInterface;

public class Utils {
    private Activity activity;
    private ProgressDialog dialog;
    public Utils(Activity activity) {
        this.activity = activity;

        dialog=new ProgressDialog(activity);
        dialog.setTitle("提示！");
        dialog.setMessage("正在加载中...");
        dialog.setCancelable(false);
    }
    @JavascriptInterface
    public void show(){
        activity.runOnUiThread(()->{
            if (!dialog.isShowing()){
                dialog.show();
            }
        });
    }
    @JavascriptInterface
    public void hide(){
        activity.runOnUiThread(()->{
            if (dialog.isShowing()){
                dialog.hide();
            }
        });
    }

}
